package com.labbit.platform.commons.validator;


import com.labbit.platform.commons.validator.annotation.NotNullList;
import org.springframework.util.CollectionUtils;

import javax.validation.ConstraintValidator;
import javax.validation.ConstraintValidatorContext;
import java.util.List;

/**
 * 检查list是否为空
 * @author ChenYu
 * @date 2018/1/19 14:38
 */
public class CheckListValidator implements ConstraintValidator<NotNullList, List> {

    @Override
    public void initialize(NotNullList constraintAnnotation) {

    }

    @Override
    public boolean isValid(List value, ConstraintValidatorContext context) {
        return !CollectionUtils.isEmpty(value);
    }
}
